package com.shihb.behavioralpatterns.strategypattern;/**
 *Description:
 *Version:1.0.0
 *@author shihb
 *@date 2020/8/3 21:07
 */
public abstract  class Duck {
  private FlyStrategy flyStrategy;
  private SwimStrategy swimStrategy;

  public String getDuckType() {
    return duckType;
  }

  public void setDuckType(String duckType) {
    this.duckType = duckType;
  }

  private   String duckType;

  public FlyStrategy getFlyStrategy() {
    return flyStrategy;
  }

  public void setFlyStrategy(FlyStrategy flyStrategy) {
    this.flyStrategy = flyStrategy;
  }

  public SwimStrategy getSwimStrategy() {
    return swimStrategy;
  }

  public void setSwimStrategy(SwimStrategy swimStrategy) {
    this.swimStrategy = swimStrategy;
  }
  public void fly(){
    if(this.flyStrategy!=null){
      System.out.println(this.duckType);
      this.flyStrategy.fly();
    }
  }
  public void swim(){
    if(this.swimStrategy!=null){
      System.out.println(this.duckType);
      this.swimStrategy.swim();
    }
  }
}
